#lang racket
;; By Spencer Hale

(require "Helper.scm")

(provide makevectorbase setpossibilitiesinitial)

;Make the possibility vectors
(define makevectorbase
  (lambda (num1 val)
    (makevector2 (make-vector num1) num1 num1 val)))

(define makevector2
  (lambda (vec num1 num2 val)
    (if (zero? num1) vec
        (and (vector-set! vec (- (vector-length vec) num1) (makevector3 (make-vector num2) num2 num2 val))
             (makevector2 vec (- num1 1) num2 val)
             ))))

(define makevector3
  (lambda (vec num1 num2 val)
    (if (zero? num1) vec
        (and (vector-set! vec (- (vector-length vec) num1) (make-vector num2 val))
             (makevector3 vec (- num1 1) num2 val))
        ))) 


;starter to set up initial possibilities for each square in matrix, going left to right
(define setpossibilitiesinitial
  (lambda (matrix possvec pos1 pos2)
    (cond  ((not (zero? (vector-ref (vector-ref matrix pos1) pos2)))
            (vector-fill! (vector-ref (vector-ref possvec pos1) pos2) #f)))
    (if (settaken possvec (vector-ref (vector-ref matrix pos1) pos2) pos1 pos2)
        (if (equal? pos1 8)
            (if (equal? pos2 8) possvec
                (setpossibilitiesinitial matrix possvec pos1 (+ pos2 1)))
            (if (equal? pos2 8)
                (setpossibilitiesinitial matrix possvec (+ pos1 1) 0)
                (setpossibilitiesinitial matrix possvec pos1 (+ pos2 1)))) 
        #f)))